home *** CD-ROM | disk | FTP | other *** search
/ EnigmA Amiga Run 1999 March / EnigmA AMIGA RUN 35 (1999)(G.R. Edizioni)(IT)[!][issue 1999-03].iso / earcd / devel / vbcc-wos / machines / amigawos / include / string.h < prev    next >
C/C++ Source or Header  |  1999-01-01  |  3KB  |  85 lines

  1. /* string.h - vbcc PowerOpen/WarpOS */
  2.  
  3. #ifndef __STRING_H
  4. #define __STRING_H 1
  5.  
  6. #ifndef __SIZE_T
  7. #define __SIZE_T 1
  8. typedef unsigned long size_t;
  9. #endif
  10.  
  11. #undef NULL
  12. #define NULL ((void *)0)
  13.  
  14. void *memcpy(void *s1,const void *s2,size_t n);
  15. void *memmove(void *,const void *,size_t);
  16. void *memset(void *,int,size_t);
  17. int memcmp(const void *,const void *,size_t);
  18. void *memchr(const void *,int,size_t);
  19. char *strcat(char *,const char *);
  20. char *strncat(char *,const char *,size_t);
  21. char *strchr(const char *,int);
  22. size_t strcspn(const char *,const char *);
  23. char *strpbrk(const char *,const char *);
  24. char *strrchr(const char *,int);
  25. size_t strspn(const char *,const char *);
  26. char *strstr(const char *,const char *);
  27. char *strtok(char *,const char *);
  28. char *strerror(int);
  29.  
  30. /* PowerPC inline functions */
  31. size_t strlen(__reg("r3") const char *) =
  32.                 "\tsubi\tr4,r3,1\n"
  33.                 "#barrier\n"
  34.                 "\tlbzu\t0,1(r4)\n"
  35.                 "\tcmpwi\tr0,0\n"
  36.                 "\tbne\t$-8\n"
  37.                 "\tsub\tr3,r4,r3";
  38. char *strcpy(__reg("r3") char *, __reg("r4") const char *) =
  39.                 "\tsubi\tr5,r3,1\n"
  40.                 "\tsubi\tr4,r4,1\n"
  41.                 "#barrier\n"
  42.                 "\tlbzu\t0,1(r4)\n"
  43.                 "\tstbu\t0,1(r5)\n"
  44.                 "\tcmpwi\tr0,0\n"
  45.                 "\tbne\t$-12";
  46. char *strncpy(__reg("r3") char *, __reg("r4") const char *,
  47.               __reg("r5") size_t) =
  48.                 "\tcmpwi\tr5,0\n"
  49.                 "\tbeq\t$+36\n"
  50.                 "\tmtctr\tr5\n"
  51.                 "\tsubi\tr5,r3,1\n"
  52.                 "#barrier\n"
  53.                 "\tlbz\tr0,0(r4)\n"
  54.                 "\tstbu\tr0,1(r5)\n"
  55.                 "\tcmpwi\tr0,0\n"
  56.                 "\tbeq\t$+8\n"
  57.                 "\taddi\tr4,r4,1\n"
  58.                 "\tbdnz\t$-20";
  59. int strcmp(__reg("r3") const char *, __reg("r4") const char *) =
  60.                 "\tsubi\tr5,r3,1\n"
  61.                 "\tsubi\tr4,r4,1\n"
  62.                 "#barrier\n"
  63.                 "\tlbzu\tr3,1(r5)\n"
  64.                 "\tlbzu\tr6,1(r4)\n"
  65.                 "\tsub.\tr3,r3,r6\n"
  66.                 "\tbne\t$+12\n"
  67.                 "\tcmpwi\tr6,0\n"
  68.                 "\tbne\t$-20";
  69. int strncmp(__reg("r3") const char *, __reg("r4") const char *,
  70.             __reg("r5") size_t) =
  71.                 "\tsubi\tr6,r3,1\n"
  72.                 "\tli\tr3,0\n"
  73.                 "\tcmpwi\tr5,0\n"
  74.                 "\tbeq\t$+36\n"
  75.                 "\tsubi\tr4,r4,1\n"
  76.                 "\tmtctr\tr5\n"
  77.                 "#barrier\n"
  78.                 "\tlbzu\tr3,1(r6)\n"
  79.                 "\tlbzu\tr5,1(r4)\n"
  80.                 "\tsub.\tr3,r3,r5\n"
  81.                 "\tbne\t$+12\n"
  82.                 "\tcmpwi\tr5,0\n"
  83.                 "\tbdnzf\t2,$-20";
  84. #endif
  85.